// pages/operat/codeManager/codeApply/codeApply.js
const LApp = getApp();
import _global from "../../../../source/js/global.js";
Page({

  /**
   * 页面的初始数据
   */
 data: {
  pageIndex: 1,
  pageSize: 15,
  searchKey: "",
  CodeApplyList: []

 },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
  if (!LApp.globalData.userInfo) {
   wx.navigateTo({
    url: '../../my/logon/logon',
   })
  }
 },
   
  

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {
   this.getUserCodeApplyList();
  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {
    this.setData({
      open: -1
    })
  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {
   wx.stopPullDownRefresh();
  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  },
  getUserCodeApplyList:function(){
    let _this = this;
    LApp._get({
      url:"nbapi/codemanager/code/apply/getlist",
      data: { enterpriseId: LApp.globalData.userInfo.EnterpriseId, userId: LApp.globalData.userInfo.UserID},
      success:function(r){
        _this.data.UserCodeApplyList =r;
        _this.setData(_this.data);
      }
    })
  },
  gocodeApplyAdd:function(){
    wx.navigateTo({
      url: 'codeApplyAdd/codeApplyAdd',
    })
  }, 
  /**
   * 右滑操作 Begin
  */
  touchMove: _global.Tap_Dray,
  tap_end: _global.Tap_End,
   /**
   * 右滑操作 End
  */
  DeleteCodeApply:function(e){
    var _model = e.currentTarget.dataset.codemodel;
    if (_model){
     let _this = this;
     if(_model.Verify == 1){
       wx.showModal({
         title: '提示',
         content: '审核通过不可删除',
         showCancel:false
       })
       return;
     }
     wx.showModal({
       title: '注意',
       content: '是否删除当前审请?',
       success:function(){
          LApp._get({
            url:"nbapi/codemanager/code/apply/delete",
            data: { Id: _model.ID, userId: LApp.globalData.userInfo.UserID},
            success:function(r){
              _this.open = -1;
              _this.getUserCodeApplyList();
            }
          })
       }
     })
   }
  }
})